//package com.neuedu.hisadmin.controller;
//
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.stereotype.Controller;
//
///**
// * <p>
// *  前端控制器
// * </p>
// *
// * @author jaun
// * @since 2025-07-04
// */
//@Controller
//@RequestMapping("/scheduling")
//public class SchedulingController {
//
//}
// src/main/java/com/neuedu/hisadmin/controller/SchedulingController.java
package com.neuedu.hisadmin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.hisadmin.dto.DoctorScheduleDTO;
import com.neuedu.hisadmin.dto.Result;
import com.neuedu.hisadmin.dto.RuleDTO;
import com.neuedu.hisadmin.entity.Scheduling;
import com.neuedu.hisadmin.service.ISchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/scheduling")
public class SchedulingController {

    @Autowired
    private ISchedulingService schedulingService;
    @GetMapping("/doctor")
    public Result<List<DoctorScheduleDTO>> getDoctorSchedules(
            @RequestParam String deptName,
            @RequestParam String doctorName,
            @RequestParam String registLevel) {

        List<DoctorScheduleDTO> schedules = schedulingService.getDoctorSchedules(
                deptName, doctorName, registLevel
        );

        return Result.success(schedules);
    }
    // 带条件查询（参数与前端表单对齐）
    @PostMapping("/search")
    public List<DoctorScheduleDTO> searchRule(@RequestBody Map<String, String> params) {
        String deptName = params.get("deptName");   // 对应前端的“所属科室”
        String doctorName = params.get("doctorName"); // 对应前端的“医生姓名”
        String registLevel = params.get("registLevel");

        return schedulingService.getSchedulingWithRelationsByCondition(deptName, doctorName, registLevel);
    }

    @PutMapping("/update")
    public Result<Boolean> update(@RequestBody Scheduling scheduling) {
    return schedulingService.updateScheduling(scheduling);
}
    @DeleteMapping("/delete/{id}")
    public boolean deleteScheduling(@PathVariable Long id){
        return schedulingService.removeById(id);
    }
}


























//
//    @GetMapping("/plan/query")
//    public Result<List<DoctorScheduleDTO >> querySchedulingPlan(
//            @RequestParam(required = false) String deptName,    // 科室名称
//            @RequestParam(required = false) String doctorName,  // 医生姓名
//            @RequestParam(required = false) String scheduleDate, // 排班日期（格式：YYYY-MM-DD）
//            @RequestParam(required = false) String noonType      // 午别（上午/下午/晚上）
//    ) {
//        List<DoctorScheduleDTO > plans = schedulingService.querySchedulingPlan(
//                deptName, doctorName, scheduleDate, noonType
//        );
//        return Result.success(plans);
//    }